//package com.cq.hd.admin.shiro;
//
//import org.apache.shiro.authc.AuthenticationException;
//import org.apache.shiro.authc.AuthenticationInfo;
//import org.apache.shiro.authc.AuthenticationToken;
//import org.apache.shiro.authc.pam.AuthenticationStrategy;
//import org.apache.shiro.authc.pam.ModularRealmAuthenticator;
//import org.apache.shiro.realm.Realm;
//import org.springframework.stereotype.Component;
//
//import java.util.Collection;
//
//@Component
//public class CustomModularRealmAuthenticator extends ModularRealmAuthenticator {
//
//    /**
//     * 重写doMultiRealmAuthentication，抛出异常，便于自定义ExceptionHandler捕获
//     */
//    @Override
//    public AuthenticationInfo doMultiRealmAuthentication(Collection<Realm> realms, AuthenticationToken token) throws AuthenticationException {
//        AuthenticationStrategy strategy = this.getAuthenticationStrategy();
//        AuthenticationInfo aggregate = strategy.beforeAllAttempts(realms, token);
//        for (Realm realm : realms) {
//            aggregate = strategy.beforeAttempt(realm, token, aggregate);
//            if (realm.supports(token)) {
//                AuthenticationInfo info = null;
//                Throwable t = null;
//                info = realm.getAuthenticationInfo(token);
//                aggregate = strategy.afterAttempt(realm, token, info, aggregate, t);
//            }
//        }
//        aggregate = strategy.afterAllAttempts(token, aggregate);
//        return aggregate;
//    }
//
//}
